package com.itheima.mm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.mm.pojo.permission.Permission;
import org.apache.ibatis.annotations.*;

public interface PermissionMapper extends BaseMapper <Permission> {
    @Update("update pe_permission_point_extend set code=#{code} where permission_id=#{id} ")
    void updatePointCode(@Param("id") Integer id, @Param("code") String code);

    @Update("update pe_permission_menu_extend set code=#{code} where permission_id=#{id} ")
    void updateMenuCode(@Param("id") Integer id, @Param("code") String code);

    @Select("select  code from  pe_permission_menu_extend  where permission_id=#{id}")
    String seleteMenuCode(Integer id);

    @Select("select  code from  pe_permission_point_extend  where permission_id=#{id}")
    String seletePointCode(Integer id);

    @Delete("delete from  pe_permission_point_extend where where permission_id=#{id} ")
    void deletePoint(Integer id);

    @Delete("delete from  pe_permission_menu_extend where where permission_id=#{id} ")
    void deleteMenu(Integer id);
    @Insert("insert into pe_permission_point_extend values(null,#{code},#{id})")
    void addPoint(@Param("id") Integer permissionId, @Param("code") String code);
    @Insert("insert into pe_permission_menu_extend values(null,#{code},#{id})")
    void addMenu(@Param("id") Integer permissionId, @Param("code") String code);

    @Select("select  id from  pe_permission_point_extend  where permission_id=#{id}")
    Integer getPointId(Integer permissionId);
    @Select("select  id from  pe_permission_menu_extend  where permission_id=#{id}")
    Integer getMenuId(Integer permissionId);
}
